<template>
  <div>
    <el-dialog title="修改" :visible.sync="info.isshow" @close="close">
      {{ user }}
      <el-form :model="user">
        <el-form-item label="手机号" label-width="120px">
          <el-input v-model="user.phone" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="昵称" label-width="120px">
          <el-input v-model="user.nickname" autocomplete="off"></el-input>
        </el-form-item>
        <!-- <el-form :model="user"> -->
        <el-form-item label="密码" label-width="120px">
          <el-input
            show-password
            v-model="user.password"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="状态" label-width="120px">
          <el-switch
            v-model="user.status"
            :active-value="1"
            :inactive-value="2"
          ></el-switch>
        </el-form-item>
      </el-form>
      <!-- </el-form> -->

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="edit">修改</el-button>
        <!-- <el-button type="primary" v-if="info.isAdd">添 加</el-button>
        <el-button type="primary" v-else>修改</el-button> -->
      </div>
    </el-dialog>
  </div>
</template>

<script>

import {
  reqroleadd,
  reqroleinfo,
  reqmenulist,
  reqroleedit,
  reqrolelist,
  requseradd,
  requserinfo,
  requseredit,
  reqmemberinfo,
  reqmemberedit,
} from "../../../http/api";
import { successAlert, errorAlert } from "../../../utils";
export default {
  props: ["info"],
  data() {
    return {
      user: {
        nickname: "",
        password: "",
        phone: "",
        randstr: "",
        status: 1,
        uid: "",
      },
    };
  },
  mounted() {
    // this.getOne()
  },
  methods: {
    empty(){
      this.user = {
        nickname: "",
        password: "",
        phone: "",
        randstr: "",
        status: 1,
        uid: "",
      }
    },
    close() {
      this.info.isshow = false;
    },
    edit() {
      reqmemberedit({
        uid: this.user.uid,
        nickname: this.user.nickname,
        phone: this.user.phone,
        password: this.user.password,
        status: this.user.status,
      }).then(res => {
        console.log(res);
        this.info.isshow = false;
        this.empty()
        this.$emit('init')
        successAlert(res.data.msg)
      })
    },
    getOne(uid) {
      reqmemberinfo({ uid }).then((res) => {
        console.log(res);
        this.user = res.data.list;
      });
    },
  },
};
</script>

<style>
</style>